package com.kh.samr.service.impl;

import com.kh.samr.entity.plan_project.PlanProjectInfo;
import com.kh.samr.repository.IPlanProjectInfoRepository;
import com.kh.samr.service.IPlanProjectInfoService;
import com.kh.samr.utils.ResultDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;

/**
 * 计划项目信息业务实现类
 *
 * @author Harry
 * @date 2020/12/29
 */
@Service
@Transactional
public class PlanProjectInfoServiceImpl implements IPlanProjectInfoService {
	
	private static final Logger log = LoggerFactory.getLogger(PlanProjectInfoServiceImpl.class);
	
	@Resource
	IPlanProjectInfoRepository planProjectInfoRepository;
	
	@Override
	public ResultDto<List<PlanProjectInfo>> findAllPlanProjectInfo() {
		log.info("方法名称：findAllPlanProjectInfo;参数：" + null);
		ResultDto<List<PlanProjectInfo>> result = new ResultDto<>();
		List<PlanProjectInfo> projectInfoList = this.planProjectInfoRepository.findAll();
		result.setErrcode(0);
		result.setList(projectInfoList);
		log.info("方法名称：findAll;返回值：" + result.toString());
		return result;
	}
	
	@Override
	public ResultDto<List<PlanProjectInfo>> findPlanProjectInfosByCreatTime(Date creatTime) {
		log.info("方法名称：findPlanProjectInfosByCreatTime;参数：creatTime:" + creatTime);
		ResultDto<List<PlanProjectInfo>> result = new ResultDto<>();
		List<PlanProjectInfo> projectInfoList = this.planProjectInfoRepository
				.findPlanProjectInfosByCreatTimeGreaterThanEqual(creatTime);
		result.setErrcode(0);
		result.setList(projectInfoList);
		log.info("方法名称：findPlanProjectInfosByCreatTime;返回值：" + result.toString());
		return result;
	}
}
